#include <stdio.h>
struct tree {
    char val;
    struct tree* left;
    struct tree* right;
};
struct tree* create(char* s, int* i)
{
    if (s[*i] == '#')
    {
        (*i)++;
        return NULL;
    }
    struct tree* root = (struct tree*)malloc(sizeof(struct tree));
    root->val = s[(*i)++];
    root->left = create(s, i);
    root->right = create(s, i);
    return root;
}
void inorder(struct tree* root)
{
    if (root == NULL)
        return;
    inorder(root->left);
    printf("%c ", root->val);
    inorder(root->right);
}
int main() {
    char s[100];
    while (scanf("%s", s) != EOF)
    {
        int i = 0;
        struct tree* root = create(s, &i);
        inorder(root);
    }

    return 0;
}